<template>
  <base-layout>
    <template #searchPanel>
      <search-panel
        :selectPer="'user:page'"
        @search="search"
        :showSearchButton="true"
        :showAddButton="false"
      >
        <job-shop
          v-model="form.storeId"
          placeholder="所属门店"
        />
        <el-input
          v-model="form.userName"
          clearable
          placeholder="员工姓名"
          style="width: 200px"
        />
      </search-panel>
    </template>
    <template #contentPanel>
      <data-table
        :value="tableData"
        :total-count="totalCount"
        :has-action="true"
        :table-column-attributes="tableColumnAttributes"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :width="160"
      >
        <template #action="{ row }">
          <i
            class="el-icon-edit"
            title="编辑1"
            style="cursor: pointer"
            @click="handleDataUpdateEdit(row)"
          ></i>
        </template>
      </data-table>
    </template>
  </base-layout>
</template>
<script>
import baseMixin from '@/mixins/base'
import { dataList } from '@/api/after-sale/systemManage/authority';
export default {
  mixins: [
    baseMixin({
      idName: 'id',
      findData: dataList,
      dataName: ['content', 'totalRecords'],
    }),
  ],
  data () {
    return {
      form: {
        storeId: '',
        userName: '',
      },
      tableColumnAttributes: [
        { name: '任职门店', value: 'storeName', type: 'text' },
        { name: '员工姓名', value: 'userName', type: 'text' },
        { name: '用户名', value: 'account', type: 'text' },
        { name: '员工职位', value: 'roleName', type: 'text' },
        { name: '职位权限', value: 'roleMenu', type: 'text' },
        { name: '单独授权', value: 'authInfo', type: 'text' },
        { name: '授权时间', value: 'lastAuthTime', type: 'text' },
      ],
    }
  },
  methods: {
    search (form) {
      this.searchOptions = {
        userName: this.form.userName,
        storeId: this.form.storeId,
      }
      this.currentPage = 1
      this.setTableData()
    },
    handleDataUpdateEdit (row, type) {
      this.$router.push({
        path: '/systemManage/authorityInfo',
        query: {
          id: row.id,
          row: JSON.stringify(row),
        }
      })
      console.log('编辑或删除')
    },
  },
}
</script>
